import axios from 'axios'
import store from '@/store/index.js'

export const request = axios.create({
  baseURL: 'http://toutiao.itheima.net/'
})

// 响应拦截器 设置公共的请求头
request.interceptors.request.use(config => {
  if (store.state.user.token) {
    config.headers.Authorization = `Bearer ${store.state.user.token}`
  }
  return config
})
